package cn.gson.crm.controller.position;

import java.util.List;
import java.util.Map;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.gson.crm.controller.BaseServlet;
import cn.gson.crm.model.dao.PositionDao;
import cn.gson.crm.model.entity.Position;

/**
 * Servlet implementation class PositionManagerServlet
 */
@WebServlet("/position/manager")
public class PositionManagerServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
       private PositionDao positionDao = new PositionDao();

	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception{
		String p = request.getParameter("page");
		String pname = request.getParameter("pname");
		String pdiscrible = request.getParameter("pdiscrible");
		if (p == null || p.isEmpty()) {
			p = "1";
		}
		Integer page = Integer.parseInt(p);
		List<Position> positionList = positionDao.getPagePositionListByType(pname, pdiscrible, 1, page);
	
		int totalPage = positionDao.getTotalPage(1,pname,pdiscrible);
		request.setAttribute("queryString", noPageQueryString(request));
		request.setAttribute("positionList", positionList);
		request.setAttribute("totalPage", totalPage);
		request.setAttribute("page", page);
		getServletPathAndForward1(request, "position/position_manager.jsp");
		//forward("position/position_manager.jsp");
	}
}

